<template>
	<view class="card-page">
		<z-paging ref="paging" v-model="dataList" @query="queryList">
			<view slot="top">
				<view class="card-title">
					<view class="left-item">
						<image src="/static/common/icon_lb.png" class="card-icon"></image>
						<view>我的月卡({{dataToatl}})</view>
					</view>
				</view>
			</view>
			<view class="card-list">
				<view class="card-item" v-for="(item,index) in dataList" :key="index">
					<image :src="item.image" class="item-left"></image>
					<view class="item-center">
						<view class="item-title">{{item.name}}</view>
						<view class="item-type">有效期:{{item.card_day}}个月</view>
						<view class="item-time">有效至:{{item.end_time}}</view>
						<view class="button-group">
							<view class="button button1"
								@click="$Tips('/pages/courses/saveCourses?card_id='+item.id+'&courses_id='+item.course_id)">预约
							</view>
							<view class="button button1"
								@click="$Tips('/pages/mine/reservationRecord?card_id='+item.id+'&courses_id='+item.course_id)">
								预约记录
							</view>
						</view>
					</view>
					
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataToatl: 0,
				dataList: [],
			}
		},
		onShow() {
			this.refreshList()
		},
		methods: {
			refreshList() {
				this.$refs.paging.scrollToTop()
				this.$refs.paging.refresh();
			},
			queryList(pageNo, pageSize) {
				this.$Api.user.getMyMonthCard({
					page: pageNo,
					limit: pageSize,
				}).then(res => {
					this.dataToatl = res.data.total
					this.$refs.paging.complete(res.data.data);
				}).catch(res => {
					this.$refs.paging.complete(false);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.card-page {
		width: 100%;
		min-height: 100vh;
		background: #F6F6F8;

		.card-title {
			margin: 22rpx 30rpx 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 28rpx;
			color: #000000;

			.left-item {
				display: flex;
				align-items: center;
				font-weight: bold;
			}

			.card-icon {
				width: 24rpx;
				height: 24rpx;
				margin-right: 12rpx;
			}
		}

		.card-list {
			margin: 0rpx 30rpx;

			.card-item {
				display: flex;
				align-items: center;
				margin-bottom: 20rpx;
				box-sizing: border-box;
				padding: 26rpx 20rpx;
				box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0, 0, 0, 0.1), inset 0rpx 2rpx 2rpx 0rpx #FFFFFF;
				border-radius: 28rpx;
				background: #ffffff;

				.item-left {
					width: 156rpx;
					height: 156rpx;
					margin-right: 20rpx;
				}

				.item-center {
					flex: 1;
					min-height: 156rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.item-title {
						font-weight: bold;
						font-size: 32rpx;
					}

					.item-type {
						font-size: 24rpx;
						width: max-content;
						padding: 0 20rpx;
						height: 40rpx;
						line-height: 40rpx;
						text-align: center;
						color: #ffffff;
						background: #A3C616;
						border-radius: 8rpx;
						margin-top: 10rpx;
					}

					.item-time {
						font-size: 26rpx;
						color: #565656;
						margin-top: 16rpx;
					}
				}
				.button-group{
					display: flex;
					align-items: center;
					justify-content: flex-end;
					margin-top: 10rpx;
				}
				.button {
					padding: 0 20rpx;
					height: 56rpx;
					font-weight: bold;
					font-size: 28rpx;
					line-height: 56rpx;
					text-align: center;
					border-radius: 44rpx;
					margin-left: 20rpx;
				}

				.button1 {
					color: #FFFFFF;
					box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(162, 198, 22, 0.3);
					background: linear-gradient(90deg, #C1ED1F 0%, #A3C616 100%);
				}
			}
		}
	}
</style>